const typescript = require("@rollup/plugin-typescript");
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
const polyfill = require("./rollup-plugin-polyfill/dist/rollup-plugin-polyfill");
const inject = require("@rollup/plugin-inject");
const json = require("@rollup/plugin-json");
const { resolve: path_resolve } = require("path");

// // jsonwebtoken
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\node-jsonwebtoken-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\jsonwebtoken.js";

// // jws
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\node-jws-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\jws.js";

// // jwa
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\node-jwa-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\jwa.js";

// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\crypto-browserify-master\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\crypto-browserify.js";
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\global-var-test\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\global-var-test.js";

// var input =
//   "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\source\\global-var-test\\index.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\dist\\global.dist.js";

var input =
  "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\source\\newsie-master-new\\src\\index.ts";
var output =
  "C:\\Users\\Administrator\\Desktop\\gitee\\n2o\\dist\\rollup-dist\\newsie\\newsie-new.js";
module.exports = {
  input,
  output: {
    file: output,
    format: "es",
  },
  plugins: [
    typescript(),
    commonjs(),
    resolve(),
    polyfill(),
    json(),
    inject({
      modules: {
        URL: [
          path_resolve("./rollup-plugin-polyfill/polyfills/dist/url.js"),
          "URL",
        ],
        URLSearchParams: [
          path_resolve("./rollup-plugin-polyfill/polyfills/dist/url.js"),
          "URLSearchParams",
        ],
        Buffer: [
          path_resolve("./rollup-plugin-polyfill/polyfills/dist/buffer.js"),
          "Buffer",
        ],
        process: path_resolve(
          "./rollup-plugin-polyfill/polyfills/dist/process.js"
        ),
      },
    }),
  ],
};
